"""
登录页面对象，用于封装登录页要进行的所有操作
"""
from selenium.webdriver.common.by import By
from selenium import webdriver

from commns.pom01.base.base_page import BasePage


class LoginPage(BasePage):
    # url
    url = 'http://39.98.138.157/shopxo/index.php?s=/index/user/logininfo'

    # 页面元素
    username =(By.NAME, 'acconut')
    pwd = (By.NAME, 'pwd')
    button = (By.XPATH, "/html/body/div[4]/div/div[2]/div[2]/div/div/div[1]/form/div[4]/button")

    # 登录业务实现
    def login(self,text,pwd):
        self.open(LoginPage.url)
        self.input(self.username, text)
        self.input(self.pwd, pwd)
        self.click(self.button)


if __name__ == '__main__':
    driver = webdriver.Chrome()
    username = 'xuzhu666'
    password = '123456'
    lp = LoginPage(driver)
    lp.login(username, password)
